package sort;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yi
 * Date: 2024-07-26
 * Time: 22:06
 */
public class InsertSort {
    public static void sort(int[] array){
        for (int i = 1; i < array.length; i++) {
            int tmp = array[i];
            int j = i - 1;
            for (; j >= 0; j--) {
                if(tmp < array[j]){
                    array[j+1] = array[j];
                }else{
                    break;
                }
            }
            array[j+1] = tmp;
        }
    }
}
